#include #include using namespace std; void stringIO() { string s; cout << "enter a word: "; cin >> s; cout << s << endl; cin.ignore(1); cout << "enter a sentence: "; getline(cin,s); cout << s << endl; } void stringLength() { string s = "asdfasdfasdf"; cout << "the lenght of s is " << s.length() << endl; } void stringAssignment() { string s = "this is a test"; string s2 = s; cout << s2 << endl; s2 = "junk"; cout << s << endl; } void stringCompare() { string s = "password"; if(s == "password") //if(stricmp(s.c_str(),"password")==0) { cout << "That is my password" << endl; } } void stringAppend() { string s = "This is the"; string s2 = " day the Lord has made."; //s.append(s2); s = s + s2; s += s2; cout << s << endl; } void singleChar() { string s = "ABCDEFGHI"; cout << s[4] << endl; cout << s.at(4) << endl; } void substring() { string s = "This is the day the Lord has made"; string s2 = s.substr(8,7); cout << s2 << endl; } void find() { string s = "This is the day the Lord has made"; cout << string::npos << endl; if(s.find("Lord") != string::npos) { cout << "found it at index " << s.find("Lord") << endl; } } void main() { //stringIO(); //stringLength(); //stringAssignment() //stringCompare(); //stringAppend(); //singleChar(); //substring(); //find(); }